export const STORAGE_KEYS = {
  USER: 'mall_user',
  ADMIN_USER: 'mall_admin_user',
  CART: 'mall_cart',
  PRODUCTS: 'mall_products',
  CATEGORIES: 'mall_categories',
  ORDERS: 'mall_orders',
  ROLES: 'mall_roles', 
} as const;

export class Storage {
  static set<T>(key: string, value: T): void {
    try {
      localStorage.setItem(key, JSON.stringify(value));
    } catch (error) {
      console.error('Storage set error:', error);
    }
  }

  static get<T>(key: string): T | null {
    try {
      const item = localStorage.getItem(key);
      return item ? JSON.parse(item) : null;
    } catch (error) {
      console.error('Storage get error:', error);
      return null;
    }
  }

  static remove(key: string): void {
    try {
      localStorage.removeItem(key);
    } catch (error) {
      console.error('Storage remove error:', error);
    }
  }

  static clear(): void {
    try {
      localStorage.clear();
    } catch (error) {
      console.error('Storage clear error:', error);
    }
  }
}
